package com.junzhiit.nengji.model.enums;

import com.bainaeco.framework.exception.InvalidArgumentException;

public enum CouponsGrantType {
	UNCONDITIONAL(0,"无条件"),
	CONSUMED(1,"消费满N发放"),
	ACTIVITIES(2,"活动发放"),
	NEW_USER_REGISTRATION(3,"新用户注册发放");
	
	private Integer value;
	
	private String text;
	
	public int toIntValue(){
		return this.value;
	}
	
	public String toStringText() {
		return this.text;
	}
	
	private CouponsGrantType(Integer value,String text){
		this.value = value;
		this.text = text;
	}
	
	public static CouponsGrantType toType(int value) {
		if (UNCONDITIONAL.value == value) {
			return UNCONDITIONAL;
		} else if(CONSUMED.value == value){
			return CONSUMED;
		} else if(ACTIVITIES.value == value){
			return ACTIVITIES;
		} else if(NEW_USER_REGISTRATION.value == value){
			return NEW_USER_REGISTRATION;
		} else {
			throw new InvalidArgumentException("Unknown CouponsType[" + value + "].");
		}
	}
}
